//package com.huidu.bitrade.config;
//
//import com.huidu.bitrade.memberstar.MemberStarConfig;
//import com.huidu.bitrade.memberstar.MemberStarEnum;
//import com.google.common.collect.Maps;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.collections4.CollectionUtils;
//import org.springframework.beans.BeansException;
//import org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import java.util.List;
//import java.util.Map;
//import java.util.Objects;
//
///**
// * 实现{@link ConfigurationPropertiesBindingPostProcessor} 接口，重写 postProcessBeforeInitialization方法，获取修改后的数据
// *
// */
//@Configuration
//@Primary
//@Slf4j
//public class DynamicUpdateMemberStar extends ConfigurationPropertiesBindingPostProcessor {
//
//    private static Map<Integer,MemberStarConfig> map = Maps.newHashMap();
//
//    @Override
//    public Object postProcessBeforeInitialization(Object bean, String beanName)
//            throws BeansException {
//        Object object = super.postProcessBeforeInitialization(bean, beanName);
//        if(bean instanceof MemberStarProperties){
//            MemberStarProperties memberStarProperties = (MemberStarProperties)bean;
//            List<MemberStarConfig> memberStarList = memberStarProperties.getMemberStarList();
//            if(CollectionUtils.isNotEmpty(memberStarList)){
//                log.info("================Nacos 动态更新属性值开始==================");
//                log.info("======================================");
//                memberStarList.forEach(this::handleUpdate);
//                log.info("================Nacos 动态更新属性值结束==================");
//            }
//        }
//        return object;
//    }
//
//    private void handleUpdate(MemberStarConfig starConfig) {
//        MemberStarConfig cacheConfig = map.get(starConfig.getLevel() + starConfig.getVersion());
//        if(Objects.isNull(cacheConfig)){
//            map.put(starConfig.getLevel() + starConfig.getVersion(), starConfig);
//            log.info("==============更新：{}===========", starConfig);
//            update(starConfig);
//        }else {
//            log.info("==============无需更新：{}===========", starConfig);
//        }
//    }
//
//    private void update(MemberStarConfig memberStarConfig){
//        MemberStarEnum.update(memberStarConfig);
////        BigDecimal hdz = MemberStarEnum.LEVEL_TWO.getHdz();
////        System.out.println(hdz);
//    }
//
//}
